<template>
	<view class="trip">
		<view class="list" v-for="(item,index) in list" :key="index">
			<view class="title flex">
				{{item.car.from_city}} 
				<image src="/static/arrow-right.png" mode="widthFix"></image>
				{{item.car.to_city}}
			</view>
			<view class="flex-between">
				<view class="left">
					<view class="p">时间：{{item.car.begin_time}}</view>
					<view class="p">车主：
						<text v-if="item.car.phone">{{item.car.phone}}</text>
						<text v-else>行程结束，电话隐藏</text>
						
					</view>
					<view class="p">人数：1人</view>
					<view class="p">上车点：{{item.location}}</view>
				</view>
				<view class="right" v-if="item.status == 1">
					<text class="p" style="color:#f00">进行中</text>
					<button class="green flex" @click="goPage(item.id)">编辑</button>
				</view>
				<view class="right" v-else>
					<text class="p">已结束</text>
					<button class="green flex" @click="goPage(item.id)">查看</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				now_page:1,
				has_more:0,
				list:[]
			};
		},
		onShow(){
			this.getList()
		},
		methods:{
			cancleOrder(id){
				
			},
			getList(){
				this.$https.get('car_apply',{
					page:this.now_page,
					page_size:10
				}).then(res=>{
					console.log(res.list)
					this.list = res.list;
					this.has_more = res.has_more;
					
				})
			},
			goPage(id){
				uni.navigateTo({
					url:"/pages/self/tripDetail?id="+id
				})
			}
		},
		onReachBottom() {
			if(this.has_more){
				this.now_page++;
				this.getList()
			}
		}
	}
</script>

<style lang="less">
	page{
		background: #f2f3f4;
	}
	@color: #4CD964;
	.trip{
		padding: 20rpx 0;
		.list{
			border-bottom: 1px solid #eee;
			background: white;
			padding: 15rpx 24rpx 24rpx;
			.title{
				font-size: 34rpx;
				image{
					width: 50rpx;
					height: auto;
					margin: 0 10rpx;
				}
			}
			.p{
				font-size: 28rpx;
				color:#999;
			}
			.right{
				text-align: right;
				button{
					height: 60rpx;
					margin: 20rpx 0;
					font-size: 28rpx;
				}
				.green{
					background:@color ;
					color:white;
				}
			}
		}
	}
</style>
